﻿using System;
using System.Configuration;
using System.Collections.Generic;
using StockTrader.DAL.IDAL;
using StockTrader.DAL.Factory;
using StockTrader.DAL.HoseAdapter.Config;
using System.IO;

namespace StockTrader.DAL.HoseAdapter.DataAccess
{
    public class Adapter
    {
        private IHoseOrders dalOrder;
        private ISecurities dalSecurities;
        private IAllMarket dalAllMarket;

        #region CTCI
        public void InsertOrderCancellation(string timestamp, string messagetype, string firm, string ordernumber, string orderentrydate, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertOrderCancellation(timestamp, messagetype, firm, ordernumber, orderentrydate, offset);

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteOrderCancelation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteOrderCancellation();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public int CountOrderCancellation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountOrderCancellation();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }

        public void InsertOrderChange(string timestamp, string messagetype, string firm, string ordernumber, string orderentrydate, string clientid, string filter, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertOrderChange(timestamp, messagetype, firm, ordernumber, orderentrydate, clientid, filter, offset);

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteOrderChange()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteOrderChange();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountOrderChange()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountOrderCancellation();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertOrderConfirmation(string timestamp, string messagetype, string firm, string orderNumber, string orderEntryDate, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertOrderConfirmation(timestamp, messagetype, firm, orderNumber, orderEntryDate, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteOrderConfirmation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteOrderConfirmation();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public int CountOrderConfirmation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountOrderConfirmation();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }

        public void InsertAdvertisement(string timestamp, string messagetype, string firm, string tradeid, string symbol, string side, long volume, string price, string board, string addcancelflag, string contact, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertAdvertisement(timestamp, messagetype, firm, tradeid, symbol, side, volume, price, board, addcancelflag, contact, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteAdvertisement()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteAdvertisement();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public int CountAdvertisement()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountAdvertisement();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }

        public void InsertOFPTDeal(string timestamp, string messagetype, string firm, string tradeid, string clientIdBuyer, string ClientIdSeller, string symbol, string price, string board, string dealid, string filter1, long borkerPortfolioVolBuyer, long brokerClientVolBuyer, long mutualFundVolBuyer, long brokerForeignVolBuyer, string filter2, long borkerPortfolioVolSeller, long brokerClientVolSeller, long mutualFundVolSeller, long brokerForeignVolSeller, string filter3, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertOneFirmPutThroughDeal(timestamp, messagetype, firm, tradeid, clientIdBuyer, ClientIdSeller, symbol, price, board, dealid, filter1, borkerPortfolioVolBuyer, brokerClientVolBuyer, mutualFundVolBuyer, brokerForeignVolBuyer, filter2, borkerPortfolioVolSeller, brokerClientVolSeller, mutualFundVolSeller, brokerForeignVolSeller, filter3, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public void DeleteOFPTDeal()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteOneFirmPutThroughDeal();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public int CountOFPTDeal()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountOneFirmPutThroughDeal();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }

        public void InsertTFPTDeal(string timestamp, string messagetype, string firmSeller, string tradeIDSeller, string ClientIdSeller, string contraFirmBuyer, string tradeIDBuyer, string symbol, string price, string board, string dealid, string filter1, long borkerPortfolioVolSeller, long brokerClientVolSeller, long mutualFundVolSeller, long brokerForeignVolSeller, string filter2, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertTwoFirmPutThroughDeal(timestamp, messagetype, firmSeller, tradeIDSeller, ClientIdSeller, contraFirmBuyer, tradeIDBuyer, symbol, price, board, dealid, filter1, borkerPortfolioVolSeller, brokerClientVolSeller, mutualFundVolSeller, brokerForeignVolSeller, filter2, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public void DeleteTFPTDeal()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteTwoFirmPutThroughDeal();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public int CountTFPTDeal()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountTwoFirmPutThroughDeal();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }

        public void InsertNewConditionedOrder(string timestamp, string messagetype, string firm, string tradeId, string orderNumber, string clientId, string symbol, string side, long volume, long publishedVolume, string price, string board, string filter, string portClientFlag, string filter2, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertNewConditionedOrder(timestamp, messagetype, firm, tradeId, orderNumber, clientId, symbol, side, volume, publishedVolume, price, board, filter, portClientFlag, filter2, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public void DeleteNewConditionedOrder()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteNewConditionedOrder();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public int CountNewConditionedOrder()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountNewConditionedOrder();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }

        public void InsertConfirmOrderCancel(string timestamp, string messagetype, string firm, long cancelshare, string ordernumber, string orderEntryDatem, string orderCancelStatus, int orderOffset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertConfirmOrderCancel(timestamp, messagetype, firm, cancelshare, ordernumber, orderEntryDatem, orderCancelStatus, orderOffset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public void DeleteConfirmOrderCancel()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteConfirmOrderCancel();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public int CountConfirmOrderCancel()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountConfirmOrderCancel();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }


        public void InsertConfirmOrderChange(string timestamp, string messagetype, string firm, string orderNumber, string orderEntryDate, string clientId, string portClientFlag, long publishVolume, string price, string filter, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertConfirmOrderChange(timestamp, messagetype, firm, orderNumber, orderEntryDate, clientId, portClientFlag, publishVolume, price, filter, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteConfirmOrderChange()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteConfirmOrderChange();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountConfirmOrderChange()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountConfirmOrderChange();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertDealConfirmation(string timestamp, string messagetype, string firm, string side, string orderNumber, string orderEntryDate, string filter, long volume, string price, string confirmNumber, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertDealConfirmation(timestamp, messagetype, firm, side, orderNumber, orderEntryDate, filter, volume, price, confirmNumber, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteDealConfirmation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteDealConfirmation();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountDealConfirmation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountDealConfirmation();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }

        public void InsertPutThroughAcknowledgement(string timestamp, string messagetype, string firmBuyer, string tradeIdBuyer, string side, string ContraFirmSeller, string tradeIdSeller, string symbol, long volume, string price, string board, string confirmNumber, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertPutThroughAcknowledgement(timestamp, messagetype, firmBuyer, tradeIdBuyer, side, ContraFirmSeller, tradeIdSeller, symbol, volume, price, board, confirmNumber, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeletePutThroughAcknowledgement()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeletePutThroughAcknowledgement();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountPutThroughAcknowledgement()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountPutThroughAcknowledgement();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertReject(string timestamp, string messagetype, string firm, string rejectReasonCode, string messageText, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertReject(timestamp, messagetype, firm, rejectReasonCode, messageText, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteReject()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteReject();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountReject()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountReject();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertCrossDealConfirm(string timestamp, string messagetype, string firm, string orderNumberBuyer, string orderEntryDateBuyer, string orderNumberSeller, string orderEntryDateSeller, long volume, string price, string confirmNumber, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertCrossDealConfirm(timestamp, messagetype, firm, orderNumberBuyer, orderEntryDateBuyer, orderNumberSeller, orderEntryDateSeller, volume, price, confirmNumber, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteCrossDealConfirm()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteCrossDealConfirm();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountCrossDealConfirm()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountCrossDealConfirm();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertPutThroughDealConfirmation(string timestamp, string messagetype, string firm, string side, string dealId, string contraFirm, long volume, string price, string confirmNumber, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertPutThroughDealConfirmation(timestamp, messagetype, firm, side, dealId, contraFirm, volume, price, confirmNumber, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeletePutThroughDealConfirmation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeletePutThroughDealConfirmation();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountPutThroughDealConfirmation()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountPutThroughDealConfirmation();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertPutThroughDealReply(string timestamp, string messagetype, string firm, string confirmNumber, string dealId, string clientIdBuyer, string replyCode, string filter, long borkerPortfolioVolBuyer, long brokerClientVolBuyer, long mutualFundVolBuyer, long brokerForeignVolBuyer, string filter2, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertPutThroughDealReply(timestamp, messagetype, firm, confirmNumber, dealId, clientIdBuyer, replyCode, filter, borkerPortfolioVolBuyer, brokerClientVolBuyer, mutualFundVolBuyer, brokerForeignVolBuyer, filter2, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeletePutThroughDealReply()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeletePutThroughDealReply();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountPutThroughDealReply()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountPutThroughDealReply();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertDealPutThroughCancelRequest(string timestamp, string messagetype, string firm, string contraFirm, string tradeId, string confirmNumber, string symbol, string side, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertDealPutThroughCancelRequest(timestamp, messagetype, firm, contraFirm, tradeId, confirmNumber, symbol, side, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteDealPutThroughCancelRequest()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteDealPutThroughCancelRequest();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountDealPutThroughCancelRequest()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountDealPutThroughCancelRequest();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public void InsertDealCancelReply(string timestamp, string messagetype, string firm, string confirmNumber, string replyCode, int offset)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.InsertDealCancelReply(timestamp, messagetype, firm, confirmNumber, replyCode, offset);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteDealCancelReply()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                dalOrder.DeleteDealCancelReply();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }

        }
        public int CountDealCancelReply()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            dalOrder.Open(Settings.CNN_STR);
            try
            {
                return dalOrder.CountDealCancelReply();

            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        #endregion CTCI

        #region PRS

        public void InsertDeList(int stockNo, string symbol, string stockType, string stockName, int sectorNo)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertDeList(stockNo, symbol, stockType, stockName, sectorNo);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeleteDeList()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteDeList();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountDeList()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountDeList();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertFroomOrigin(long stockNo, double totalRoom, double currentRoom)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertFroomOrigin(stockNo, totalRoom, currentRoom);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeleteFroomOrigin()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteFroomOrigin();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountFroomOrigin()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountFroomOrigin();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void DeleteFroom()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteFroom();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }

        public void UpdateFroom(long stockNo, double totalRoom, double currentRoom, int buy, int sell)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.UpdateFroom(stockNo, totalRoom, currentRoom, buy, sell);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertLe(long stockNo, long price, long accumulateVol, double accumulateVal, long highest, long lowest, long time)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertLe(stockNo, price, accumulateVol, accumulateVal, highest, lowest, time);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeleteLe()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteLe();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountLe()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountLe();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertLeCompact(int stockno, int price, int volume, int volp1, int valp1, int volp2, int valp2, int time)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertLeCompact(stockno, price, volume, volp1, valp1, volp2, valp2, time);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }


        public void InsertMarketStat(string controlCode, long time)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertMarketStat(controlCode, time);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeleteMarketStat()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteMarketStat();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountMarketStat()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountMarketStat();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertNewList(int stockNo, string symbol, string stockType, string stockName, int sectorNo)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertNewList(stockNo, symbol, stockType, stockName, sectorNo);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeleteNewList()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteNewList();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountNewList()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountNewList();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertPutAd(int tradeid, int stockid, long vol, double price, long firmno, string side, string board, long time, string flag)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertPutAd(tradeid, stockid, vol, price, firmno, side, board, time, flag);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeletePutAd()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeletePutAd();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountPutAd()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountPutAd();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertPutDc(int confirmNo, int stockId, long vol, long price, string board)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertPutDc(confirmNo, stockId, vol, price, board);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeletePutDc()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeletePutDc();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountPutDc()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountPutDc();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertPutExec(long confirmNo, int stockId, long vol, long price, string board)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertPutExec(confirmNo, stockId, vol, price, board);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeletePutExec()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeletePutExec();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountPutExec()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountPutExec();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void InsertSecurities(int stockNo, string symbol, string stockType, long ceiling, long floor, double bigLotValue, string securitiesName, string sectorNo, string designated, string suspension, string delist, string haltResumeFlag, string split, string benefit, string meeting, string notice, string clientIdRequest, int couponRate, string issueDate, string matureDate, long avrPrice, int parValue, string SDCFlag, long PriorClosePrice, string priorCloseDate, long projectOpen, long openPrice, long last, long lastVol, double lastVal, long highest, long lowest, double totalShare, double totalValue, int AccumulateDeal, int bigDeal, long bigVol, double bigVal, long oddVol, double oddVal, long best3Bid, long best3BidVolume, long best2Bid, long best2BidVolume, long best1Bid, long best1BidVolume, long best1Offer, long best1OfferVolume, long best2Offer, long best2OfferVolume, long best3Offer, long best3OfferVolume, int boardLost)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertSecurities(stockNo, symbol, stockType, ceiling, floor, (float)bigLotValue, securitiesName, sectorNo, designated, suspension, delist, haltResumeFlag, split, benefit, meeting, notice, clientIdRequest, couponRate, issueDate, matureDate, avrPrice, parValue, SDCFlag, PriorClosePrice, priorCloseDate, projectOpen, openPrice, last, lastVol, lastVal, highest, lowest, totalShare, totalValue, AccumulateDeal, bigDeal, bigVol, bigVal, oddVol, oddVal, best3Bid, best3BidVolume, best2Bid, best2BidVolume, best1Bid, best1BidVolume, best1Offer, best1OfferVolume, best2Offer, best2OfferVolume, best3Offer, best3OfferVolume, boardLost);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeleteSecurities()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteSecurities();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public int CountSecurities()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountSecurities();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void UpdateSecuritiesByStockSymbol(string designated, string suspension, string delist, string haltResumeFlag, string split, string benefit, string meeting, string notice, string clientIdRequest, int couponRate, string issueDate, string matureDate, long avrPrice, int parValue, string SDCFlag, long projectOpen, long last, long lastVol, double lastVal, long highest, long lowest, double totalShare, double totalValue, int AccumulateDeal, int bigDeal, long bigVol, double bigVal, long oddVol, double oddVal, long best3Bid, long best3BidVolume, long best2Bid, long best2BidVolume, long best1Bid, long best1BidVolume, long best1Offer, long best1OfferVolume, long best2Offer, long best2OfferVolume, long best3Offer, long best3OfferVolume, int boardLost, long openPrice, string symbol)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.UpdateSecuritiesByStockSymbol(designated, suspension, delist, haltResumeFlag, split, benefit, meeting, notice, clientIdRequest, couponRate, issueDate, matureDate, avrPrice, parValue, SDCFlag, projectOpen, last, lastVol, lastVal, highest, lowest, totalShare, totalValue, AccumulateDeal, bigDeal, bigVol, bigVal, oddVol, oddVal, best3Bid, best3BidVolume, best2Bid, best2BidVolume, best1Bid, best1BidVolume, best1Offer, best1OfferVolume, best2Offer, best2OfferVolume, best3Offer, best3OfferVolume, boardLost, openPrice, symbol);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }

        public void UpdateSecuritiesEarly(int stockNo, string symbol, string stockType, long ceiling, long floor, double bigLotValue, string securitiesName, string sectorNo, string designated, string suspension, string delist, string haltResumeFlag, string split, string benefit, string meeting, string notice, string clientIdRequest, int couponRate, string issueDate, string matureDate, long avrPrice, int parValue, string SDCFlag, long PriorClosePrice, string priorCloseDate, long projectOpen, long openPrice, long last, long lastVol, double lastVal, long highest, long lowest, double totalShare, double totalValue, int AccumulateDeal, int bigDeal, long bigVol, double bigVal, long oddVol, double oddVal, long best3Bid, long best3BidVolume, long best2Bid, long best2BidVolume, long best1Bid, long best1BidVolume, long best1Offer, long best1OfferVolume, long best2Offer, long best2OfferVolume, long best3Offer, long best3OfferVolume, int boardLost)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.UpdateSecuritiesEarly(stockNo, symbol, stockType, ceiling, floor, (float)bigLotValue, securitiesName, sectorNo, designated, suspension, delist, haltResumeFlag, split, benefit, meeting, notice, clientIdRequest, couponRate, issueDate, matureDate, avrPrice, parValue, SDCFlag, PriorClosePrice, priorCloseDate, projectOpen, openPrice, last, lastVol, lastVal, highest, lowest, totalShare, totalValue, AccumulateDeal, bigDeal, bigVol, bigVal, oddVol, oddVal, best3Bid, best3BidVolume, best2Bid, best2BidVolume, best1Bid, best1BidVolume, best1Offer, best1OfferVolume, best2Offer, best2OfferVolume, best3Offer, best3OfferVolume, boardLost);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }

        public void UpdateSecuritiesLately(int stockNo, string symbol, string stockType, long ceiling, long floor, double bigLotValue, string securitiesName, string sectorNo, string designated, string suspension, string delist, string haltResumeFlag, string split, string benefit, string meeting, string notice, string clientIdRequest, int couponRate, string issueDate, string matureDate, long avrPrice, int parValue, string SDCFlag, long PriorClosePrice, string priorCloseDate, long projectOpen, long openPrice, long last, long lastVol, double lastVal, long highest, long lowest, double totalShare, double totalValue, int AccumulateDeal, int bigDeal, long bigVol, double bigVal, long oddVol, double oddVal, long best3Bid, long best3BidVolume, long best2Bid, long best2BidVolume, long best1Bid, long best1BidVolume, long best1Offer, long best1OfferVolume, long best2Offer, long best2OfferVolume, long best3Offer, long best3OfferVolume, int boardLost)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.UpdateSecuritiesLately(stockNo, symbol, stockType, ceiling, floor, (float)bigLotValue, securitiesName, sectorNo, designated, suspension, delist, haltResumeFlag, split, benefit, meeting, notice, clientIdRequest, couponRate, issueDate, matureDate, avrPrice, parValue, SDCFlag, PriorClosePrice, priorCloseDate, projectOpen, openPrice, last, lastVol, lastVal, highest, lowest, totalShare, totalValue, AccumulateDeal, bigDeal, bigVol, bigVal, oddVol, oddVal, best3Bid, best3BidVolume, best2Bid, best2BidVolume, best1Bid, best1BidVolume, best1Offer, best1OfferVolume, best2Offer, best2OfferVolume, best3Offer, best3OfferVolume, boardLost);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }


        public void InsertTotalMkt(long vnIndex, long totalTrade, double totalShares, double totalVlues, double upVolume, double noChangeVolume, double downVolume, int advances, int declines, int noChange, long vn50index, string marketid, string filter, long time)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InsertTotalMkt(vnIndex, totalTrade, totalShares, totalVlues, upVolume, noChangeVolume, downVolume, advances, declines, noChange, vn50index, marketid, filter, time);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void DeleteTotalMkt()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.DeleteTotalMkt();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public int CountTotalMkt()
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                return dalSecurities.CountTotalMkt();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        #endregion PRS

        public void BackupHoseOrders()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalOrder.Open(Settings.CNN_STR);
                dalOrder.BackupHoseOrders();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void DeleteHoseOrders()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalOrder.Open(Settings.CNN_STR);
                dalOrder.DeleteHoseOrders();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();

                StreamWriter sw = null;
                FileStream fs = new FileStream("c:\\HoseLog.log", FileMode.Append, FileAccess.Write);
                using (sw = new StreamWriter(fs))
                {
                    sw.Write(DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "\r\n");
                    sw.Close();
                    fs.Close();
                }
            }
        }
        public void UpdateSecuritiesInfo(int stockno, string symbol, string market)
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalOrder.Open(Settings.CNN_STR);
                dalOrder.UpdateSecuritiesInfo(stockno, symbol, market);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }


        public int CountBackupOrders()
        {
            dalOrder = StockTrader.DAL.Factory.OrdersFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalOrder.Open(Settings.CNN_STR);
                return dalOrder.CountBackupOrders();
            }
            catch
            {
                throw;
            }
            finally
            {
                dalOrder.Close();
            }
        }
        public void InitSessionData(DateTime transDate)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.InitSessionData(transDate);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public void UpdateATOByStockNo(int stockNo, DateTime transDate)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.UpdateATOByStockNo(stockNo, transDate);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }

        }
        public void UpdateATCByStockNo(int stockNo, DateTime transDate)
        {
            dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalSecurities.Open(Settings.CNN_STR);
                dalSecurities.UpdateATCByStockNo(stockNo, transDate);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSecurities.Close();
            }
        }
        public void UpdateSession2ByStockNo(int stockNo, DateTime transDate)
        {
            {
                dalSecurities = StockTrader.DAL.Factory.SecuritiesFactory.Create(Settings.DAL_TYPE);
                try
                {
                    dalSecurities.Open(Settings.CNN_STR);
                    dalSecurities.UpdateSession2ByStockNo(stockNo, transDate);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    dalSecurities.Close();
                }
            }
        }
        public List<int> SelectStockNoByTransDate(DateTime transDate)
        {
            dalAllMarket = StockTrader.DAL.Factory.AllMarketFactory.Create(Settings.DAL_TYPE);
            try
            {
                dalAllMarket.Open(Settings.CNN_STR);
                return dalAllMarket.SelectStockNoByTransDate(transDate);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalAllMarket.Close();
            }

        }
    }
}
